<?php
class Paper_sizes_model extends MY_Model{
    
    function Paper_sizes_model(){
        parent::MY_Model();
        $this->bur_papersizes='bur_papersizes';
        $this->load->database();
    }

    	function total_paper_sizes() {
		$this->db->from($this->bur_papersizes);
	
		return $this->db->count_all_results();
	}    
    function list_paper_sizes($limit='false',$offset='false'){
    	if ($limit){
        	$limit = (int)$limit;
    		$offset = (int)$offset;
        }
		
		$this->db->order_by('papersize_id','DESC');
      

		if ($limit){
            $query = $this->db->get($this->bur_papersizes,$limit,$offset);
        }else{
            $query = $this->db->get($this->bur_papersizes);
        }
    // $query=$this->db->get($this->bur_papersizes); 
    
     if($query->num_rows()>0){
        return $query->result_array();
        
     }else{
        return false;
        
     }
    }

    function get_paper_sizes_detail($paper_sizes_id=''){
		
		$this->db->where('papersize_id',$paper_sizes_id);
	 	$query = $this->db->get($this->bur_papersizes);
		if($query->num_rows() > 0){
			return $query->row_array();
		}else{
			return FALSE;
		}
	}  
     function delete_paper_sizes($paper_sizes_id ){
        if(!empty($paper_sizes_id)){
            foreach($paper_sizes_id as $id):
            $this->db->where('papersize_id',$id);
            $this->db->delete($this->bur_papersizes);
            endforeach;
        } else {
            return False;
            
        }  
        }
    function do_action(){
        
        if($this->input->post('papersize_id'))
        {
           // echo 'edit';
           // echo $this->input->post('papersize_id');
           // echo $this->input->post('papersize_title');
            
            $this->db->set('papersize_title',$this->input->post('papersize_title'));
             $this->db->set('papersize_width',$this->input->post('papersize_width'));
              $this->db->set('papersize_height',$this->input->post('papersize_height'));
            $this->db->where('papersize_id',$this->input->post('papersize_id'));
            $this->db->update($this->bur_papersizes);
            
       }else{
           // echo 'add';
          $this->db->set('papersize_width',$this->input->post('papersize_width'));
           $this->db->set('papersize_height',$this->input->post('papersize_height'));
            $this->db->set('papersize_title',$this->input->post('papersize_title'));
          $this->db->insert($this->bur_papersizes);
            
      }
       // die();
    }
}
?>
